'use strict';

/**
*   Import underscore lib
*
*/

angular.module('underscore', [])
   .factory('_', function(){
      return window._;
  })

angular.module('Base64', [])
  .factory('$base64', function(){
    return window.Base64;
  })

/**
 * @ngdoc overview
 * @name consoleAngularUiApp
 * @description
 * # consoleAngularUiApp
 *
 * Main module of the application.
 */
angular
  .module('consoleAngularUiApp', [
    'underscore',
    'Base64',
    'ngAnimate',
    'ngCookies',
    'ngMessages',
    'ngResource',
    'ngRoute',
    'ngSanitize',
    'ui.router',
    'ui.grid',
    'ui.grid.selection',
    'pl.menu'
  ])
  .config(function($locationProvider, $stateProvider, $urlRouterProvider) {

    // Use HTML5 Mode
    $locationProvider.html5Mode(true);

    // For any unmatched url, redirect to /
    $urlRouterProvider
      .otherwise('/console');

    // Set up the states
    $stateProvider
      // url must has '/' to mark route starting from root url
      .state('login', {
        url: '/console/login',
        templateUrl: 'views/login.html'
      })

      // Route rules for home page
      .state('/', {
        url: '/console',
        templateUrl: 'views/home.html'
      })
      .state('services', {
        url: '/services',
        parent: '/',
        templateUrl: 'views/services.html',
        controller: 'servicesCtrl'
      })
      .state('services:new', {
        url: '/services/new',
        parent: '/',
        templateUrl: "views/services.new.html",
        controller: "servicesNewCtrl"
      })
  })

